/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui;

import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;

/**
 *
 * @author willem
 */
public class AexPanel extends javax.swing.JPanel {

    String pString = "";
    int position = 0;
    /**
     * Creates new form AexPanel
     */
    public AexPanel() {
        initComponents();
    }
    
    public final void setPString(String s) {
        System.out.println(s);
        pString = s;
        position += 2;
        if (position > this.getWidth()) {
            position = 0;
        }
    }
    
    @Override
    public void paintComponent(Graphics g) {
        super.paintComponent(g);
        
        g.drawString(pString, 10, 50);
        
            if (pString != null){
            g.clearRect(0, 0, g.getClipBounds().width, g.getClipBounds().height);
            g.setFont(new Font("Arial",Font.BOLD, 40));
        g.drawString(pString, position, 40);
        FontMetrics fm = g.getFontMetrics();
        int width = fm.stringWidth(pString);
        g.drawString(pString, position-width, 40);
        
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 38, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables
}
